<?php
/**
 * 加密算法类
 * 
 * @example 
 * 			$a = new Encrypt("passward","key");
 * 			echo $a->returnCode();
 * @exception 输入字符串不能为中文。但密匙可以为任意字符加密关键词；
 * @package Safety/Acthcode
 * @link www.sampeng.cn
 * @version $ID:Encrypt $Time:2008-11-22 15:38:34 SamPeng
 * @copyright SamPeng & Comsenz Inc
 */
class Encrypt extends Code {
	protected function codeString(){
		$this->keyc = self::CKEY_LENGTH  ? (substr(md5(microtime()), -self::CKEY_LENGTH )) : '';
	
		$this->cryptkey = $this->keya.md5($this->keya.$this->keyc);
		$this->key_length = strlen($this->cryptkey);
		
		$this->string = sprintf('%010d', self::EXPIRY ? self::EXPIRY + time() : 0).substr(md5($this->string.$this->keyb), 0, 16).$this->string;
	}
	
	public function returnCode(){
		return $this->keyc.str_replace('=', '', base64_encode($this->result));
	}
}
?>